/**============================================================================
 Confidential Information - Limited distribution to authorized persons only.
 This software is protected as an unpublished work under the U.S. Copyright
 Act of 1976.

 Copyright (c) 2011, BluePhoenix Solutions, Inc. All rights reserved.
 ----------------------------------------------------------------------------
 file......: DBConstants.java
 Author....: Vyacheslav Kovalyov
 Created...: 12/27/11

 Description:

 ============================================================================*/
package com.bphx.android.db;

import static com.bphx.android.db.Tables.OPTIONS;
import static com.bphx.android.db.Tables.WORDS;

/**
 * @author Vyacheslav Kovalyov
 * @version 1.0
 */
abstract class DBConstants {

    /* private const*/
    private static final String COLUMN_WORD_ID = "word_id";
    private static final String COLUMN_ORIGINAL_NAME = "word";
    private static final String COLUMN_ORIGINAL_ID = "original_word_id";
    private static final String COLUMN_VARIANT = "variant";
    private static final String COLUMN_KEY = "option_key";
    private static final String COLUMN_VALUE = "option_value";

    /* public const */
    public static final String QUERY_SEPARATOR = ";";
    public static final String DB_NAME = "wordroid.db";
    public static final int DB_VERSION = 1;
    public static final int BUFFER_SIZE = 100;

    public static final int INCORRECT_ID = -1;

    /* query */
    public static final String QUERY_BASE_SELECT = "SELECT * FROM [%s];";
    public static final String QUERY_SELECT_BY_ID = "SELECT * FROM [%s] WHERE [" + COLUMN_ORIGINAL_ID + "] = %d;";
    public static final String QUERY_SELECT_WORD_ID_BY_NAME = "SELECT " + COLUMN_WORD_ID + " FROM [" + WORDS.name() + "] WHERE [" + COLUMN_ORIGINAL_NAME + "] = \"%s\";";
    public static final String QUERY_DELTE_WORD_BY_NAME = "DELETE FROM " + WORDS.name() + " WHERE [" + COLUMN_ORIGINAL_NAME + "] = \"%s\";";
    public static final String QUERY_ADD_WORD = "INSERT INTO " + WORDS.name() + " (" + COLUMN_ORIGINAL_NAME + ") values (\"%s\");";
    public static final String QUERY_ADD_WORD_WITH_ID = "INSERT INTO " + WORDS.name() + " values (%d, \"%s\");";

    public static final String QUERY_SELECT_VARIANT = "select " + COLUMN_VARIANT + " from %s where original_word_id = %d;";
    public static final String QUERY_ADD_VARIANT = "insert into [%s] ([" + COLUMN_ORIGINAL_ID + "], [" + COLUMN_VARIANT + "]) VALUES (%d, \"%s\");";

    /* options */
    public static final String QUERY_GET_OPTION = "SELECT " + COLUMN_VALUE + " FROM [" + OPTIONS.name() + "] where " + COLUMN_KEY + " = \"%s\";";
    public static final String QUERY_SET_OPTION = "REPLACE INTO " + OPTIONS.name() + " VALUES  ('%s', '%s');";
}
